'use strict';
const path = require('path');
const projectConfig = require('../setting.js'); // 在配置生成路径时需要projectConfig中的相关信息，故预先导入
module.exports = {
  build: {
    // 服务器端配置
    env: require('./prod.env'),
    // index: path.resolve(__dirname, "../dist/index.html"),
    assetsRoot: path.resolve(__dirname, '../dist'), // 公共资源地址
    assetsSubDirectory: projectConfig.assetsSubDirectory,
    assetsPublicPath: projectConfig.assetsPublicPath,
    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    // devtool: '#source-map',
    // productionSourceMap: false, // 是否生成map文件(设成true会额外生成一份map文件方便前端调试，但为了防止反爬虫代码被破解，所以这里用了false)

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },
  dev: {
    // 本地调试配置
    env: require('./dev.env'),
    port: projectConfig.devPort, // 调试地址端口
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: projectConfig.proxyTable, // 可以在这里配置端口转发(解决本地调试时的跨域问题)

    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false

  },

  projectConfig: projectConfig

};
